class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2022-02-09",
      revision: "41553c40041b5e6f775a50c1716a54af4d5ad50a"
  version "2022-02-09"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git", branch: "master"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_monterey: "2083b09b8edd1ac76d6c4a5fb67e347eaaa78ed138af42d6715d5412a8fa9648"
    sha256 cellar: :any_skip_relocation, arm64_big_sur:  "8b6eda0b8fd5511e2f857ec9225907e33bb78e5db81556abbb1bbd7f04296bc3"
    sha256 cellar: :any_skip_relocation, monterey:       "b855c8cdad22825da0923d388f805a349b1701b120fff0bced7dd8e5050f4a4d"
    sha256 cellar: :any_skip_relocation, big_sur:        "1d1a5432aab1a3b4df84217302250362102c17fe00ff22f83f9a3cab573be325"
    sha256 cellar: :any_skip_relocation, catalina:       "50034c7f9ba04185f17080afc4b172d249dd003ace33373ce433dc63c6a00960"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "c84b8492ce22dee458e03684f9296a177298a82ba0cc40853b24a1eefa3a5b46"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
